home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 353_02 / default.cpp < prev    next >
C/C++ Source or Header  |  1992-01-18  |  945b  |  38 lines

  1.                                       // Chapter 4 - Program 4
  2. #include <iostream.h>
  3. #include <stdio.h>
  4.  
  5. int get_volume(int length, int width = 2, int height = 3);
  6.  
  7. main()
  8. {
  9. int x = 10, y = 12, z = 15;
  10.  
  11.    cout << "Some box data is " << get_volume(x, y, z) << "\n";
  12.    cout << "Some box data is " << get_volume(x, y) << "\n";
  13.    cout << "Some box data is " << get_volume(x) << "\n";
  14.  
  15.    cout << "Some box data is ";
  16.    cout << get_volume(x, 7) << "\n";
  17.    cout << "Some box data is ";
  18.    cout << get_volume(5, 5, 5) << "\n";
  19.    
  20. }
  21.  
  22. int get_volume(int length, int width, int height)
  23. {
  24.    printf("%4d %4d %4d   ", length, width, height);
  25.    return length * width * height;
  26. }
  27.  
  28.  
  29.  
  30.  
  31. // Result of execution
  32. //
  33. //   10   12   15Some box data is   1800
  34. //   10   12    3Some box data is    360
  35. //   10    2    3Some box data is     60
  36. // Some box data is   10    7    3   210
  37. // Some box data is    5    5    5   125
  38.